/*
 * @file    :drv_wdog.c
 * @module  :WDOG
 * @author  :LingFengLu
 * @date    :2023-06-06
 */

#include "drv_wdog.h"
#include "em_wdog.h"
#include "em_cmu.h"
//Constant definition    宏定义


//Global variable definition    全局变量定义


//Private variable definition    私有变量定义


//Private function declaration   私有函数申明








//Public function definition   公共函数定义
void DrvWdog_Init(void)
{
    // Enable clock for the WDOG module; has no effect on xG21
	CMU_ClockEnable(cmuClock_WDOG0, true);
	// Watchdog Initialize settings
	WDOG_Init_TypeDef wdogInit = WDOG_INIT_DEFAULT;
	CMU_ClockSelectSet(cmuClock_WDOG0, cmuSelect_ULFRCO); /* ULFRCO as clock source */
	uint32 u32_Value = CMU_ClockFreqGet(cmuClock_WDOG0);
	wdogInit.debugRun = false;
	wdogInit.em3Run = true;
	wdogInit.em2Run = true;

	wdogInit.perSel = wdogPeriod_8k; // 2049 clock cycles of a 1kHz clock  ~2 seconds period
	// Initializing watchdog with chosen settings
	WDOGn_Init(DEFAULT_WDOG, &wdogInit);
}

void DrvWdog_Feed(void)
{
    WDOGn_Feed(DEFAULT_WDOG);
}







//Private function definition   私有函数定义

